<script setup lang="ts">
/**
 * @see {@link https://vuejs.org/api/sfc-script-setup.html#defineoptions}
 */
defineOptions({
  name: "TbOrder",
  inheritAttrs: false,
});
import {
	getTbOrderPage,
} from "@/api/tbOrder";

import { TbOrderQuery } from "@/api/tbOrder/types";

const queryFormRef = ref(ElForm); // 查询表单

const loading = ref(false);
const ids = ref([]);
const total = ref(0);
const monthValue = ref('')

const queryParams = reactive<TbOrderQuery>({
  pageNum: 1,
  pageSize: 20,
});
const orderList = ref<[]>();



/**
 * 查询
 */
function handleQuery() {
  queryParams.billMonth = monthValue.value
  loading.value = true;
  getTbOrderPage(queryParams)
    .then(({ data }) => {
		orderList.value = data.list;
      total.value = data.total;
    })
    .finally(() => {
      loading.value = false;
    });
}

/** 重置查询 */
function resetQuery() {
  queryParams.pageNum = 1;
  handleQuery();
}

onMounted(() => {
  let now = new Date()
  let month = now.getMonth()
  if (month < 9){
    monthValue.value = now.getFullYear() + '0' + (now.getMonth() + 1) + ''
  }	else {
    monthValue.value = now.getFullYear() + '' + (now.getMonth() + 1) + ''
  }
  handleQuery(); // 初始化标准账单配置列表数据
});
</script>

<template>
  <div class="app-container">
    <el-row :gutter="20">

      <el-col>
        <div class="search-container">
          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
            <el-form-item label="订单月份">
              <el-date-picker
                      v-model="monthValue"
                      type="month"
                      value-format="YYYYMM"
                      :editable="false"
                      :clearable="false"
                      placeholder="选择月份"
              />
            </el-form-item>
            <el-form-item label="订单编号" prop="keywords">
              <el-input
                v-model="queryParams.keywords"
                placeholder="请输入订单编号"
                clearable
                style="width: 200px"
                @keyup.enter="handleQuery"
              />
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="resetQuery"
                ><i-ep-search />搜索</el-button
              >
              <el-button @click="resetQuery">
                <i-ep-refresh />
                重置</el-button
              >
            </el-form-item>
          </el-form>
        </div>

        <el-card shadow="never">

          <el-table
            size="small"
            :header-row-style="{color: 'dimgray'}"
            v-loading="loading"
            :data="orderList"
			border
          >
            <el-table-column
              label="订单编号"
              align="center" show-overflow-tooltip
              prop="orderNo"
              width="180"
            />
            <el-table-column
              label="支付单号"
			  width="180"
              align="center" show-overflow-tooltip
              prop="payNo"
            />
            <el-table-column
              label="支付详情"
              width="120"
              align="center" show-overflow-tooltip
              prop="payDetail"
            />

            <el-table-column
              label="买家应付货款"
              width="120"
              align="center" show-overflow-tooltip
              prop="buyerDuePayAmount"
            />

            <el-table-column
              label="买家应付邮费"
              width="120"
              align="center" show-overflow-tooltip
              prop="buyerDuePayPostage"
            />
            <el-table-column
              label="买家支付积分"
              align="center" show-overflow-tooltip
              prop="buyerPayCredits"
              width="120"
            />
            <el-table-column
              label="总金额"
              align="center" show-overflow-tooltip
              prop="totalAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="返点积分"
              align="center" show-overflow-tooltip
              prop="returnCredits"
              width="180"
            ></el-table-column>
            <el-table-column
              label="买家实际支付金额"
              align="center" show-overflow-tooltip
              prop="buyerActualPayAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="买家实际支付积分"
              align="center" show-overflow-tooltip
              prop="buyerActualPayCredits"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单状态"
              align="center" show-overflow-tooltip
              prop="orderStatus"
              width="180"
            ></el-table-column>
            <el-table-column
              label="买家留言"
              align="center" show-overflow-tooltip
              prop="buyerMessage"
              width="180"
            ></el-table-column>
            <el-table-column
              label="收货人名称"
              align="center" show-overflow-tooltip
              prop="receiverName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="收货地址"
              align="center" show-overflow-tooltip
              prop="recieverAddress"
              width="180"
            ></el-table-column>
            <el-table-column
              label="运送方式"
              align="center" show-overflow-tooltip
              prop="deliveryMethod"
              width="180"
            ></el-table-column>
            <el-table-column
              label="联系电话"
              align="center" show-overflow-tooltip
              prop="mobile"
              width="180"
            ></el-table-column>
            <el-table-column
              label="联系手机"
              align="center" show-overflow-tooltip
              prop="phone"
              width="180"
            ></el-table-column>
            <el-table-column
              label="虚拟号过期时间"
              align="center" show-overflow-tooltip
              prop="virtualNoExpireTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单创建时间"
              align="center" show-overflow-tooltip
              prop="orderCreateTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单付款时间"
              align="center" show-overflow-tooltip
              prop="orderPayTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="宝贝标题"
              align="center" show-overflow-tooltip
              prop="goodsTitle"
              width="180"
            ></el-table-column>
            <el-table-column
              label="宝贝种类"
              align="center" show-overflow-tooltip
              prop="goodsType"
              width="180"
            ></el-table-column>
            <el-table-column
              label="物流单号"
              align="center" show-overflow-tooltip
              prop="logisticsNo"
              width="180"
            ></el-table-column>
            <el-table-column
              label="物流公司"
              align="center" show-overflow-tooltip
              prop="logisticsCompany"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单备注"
              align="center" show-overflow-tooltip
              prop="remark"
              width="180"
            ></el-table-column>
            <el-table-column
              label="宝贝总数量"
              align="center" show-overflow-tooltip
              prop="goodsNum"
              width="180"
            ></el-table-column>
            <el-table-column
              label="店铺Id"
              align="center" show-overflow-tooltip
              prop="storeId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="店铺名称"
              align="center" show-overflow-tooltip
              prop="storeName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单关闭原因"
              align="center" show-overflow-tooltip
              prop="orderCloseReason"
              width="180"
            ></el-table-column>
            <el-table-column
              label="卖家服务费"
              align="center" show-overflow-tooltip
              prop="sellerServiceFee"
              width="180"
            ></el-table-column>
            <el-table-column
              label="买家服务费"
              align="center" show-overflow-tooltip
              prop="buyerServiceFee"
              width="180"
            ></el-table-column>
            <el-table-column
              label="发票抬头"
              align="center" show-overflow-tooltip
              prop="invoiceTitle"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否手机订单"
              align="center" show-overflow-tooltip
              prop="mobileOrder"
              width="180"
            ></el-table-column>
            <el-table-column
              label="分阶段订单信息"
              align="center" show-overflow-tooltip
              prop="stepOrderInfo"
              width="180"
            ></el-table-column>
            <el-table-column
              label="特权订金订单id"
              align="center" show-overflow-tooltip
              prop="privilegeOrderId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否上传合同照片"
              align="center" show-overflow-tooltip
              prop="hasUploadContract"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否上传小票"
              align="center" show-overflow-tooltip
              prop="hasUploadReceipt"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否代付"
              align="center" show-overflow-tooltip
              prop="hasPayBehalf"
              width="180"
            ></el-table-column>
            <el-table-column
              label="定金排名"
              align="center" show-overflow-tooltip
              prop="depositRank"
              width="180"
            ></el-table-column>
            <el-table-column
              label="修改后的sku"
              align="center" show-overflow-tooltip
              prop="newSku"
              width="180"
            ></el-table-column>
            <el-table-column
              label="修改后的收获地址"
              align="center" show-overflow-tooltip
              prop="newRecieveAddress"
              width="180"
            ></el-table-column>
            <el-table-column
              label="异常信息"
              align="center" show-overflow-tooltip
              prop="exceptionMessage"
              width="180"
            ></el-table-column>
            <el-table-column
              label="天猫卡券抵扣"
              align="center" show-overflow-tooltip
              prop="tmallDeduct"
              width="180"
            ></el-table-column>
            <el-table-column
              label="集分宝抵扣"
              align="center" show-overflow-tooltip
              prop="jfbDeduct"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否是O2O交易"
              align="center" show-overflow-tooltip
              prop="o2oTrade"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售交易类型"
              align="center" show-overflow-tooltip
              prop="newTradeType"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售导购门店名称"
              align="center" show-overflow-tooltip
              prop="newTradeName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售导购门店id"
              align="center" show-overflow-tooltip
              prop="newTradeId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售发货门店名称"
              align="center" show-overflow-tooltip
              prop="newTradeDeliveryName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售发货门店id"
              align="center" show-overflow-tooltip
              prop="newTradeDeliveryId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="退款金额"
              align="center" show-overflow-tooltip
              prop="returnAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="预约门店"
              align="center" show-overflow-tooltip
              prop="bookingStore"
              width="180"
            ></el-table-column>
            <el-table-column
              label="确认收货时间"
              align="center" show-overflow-tooltip
              prop="receiveTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="打款商家金额"
              align="center" show-overflow-tooltip
              prop="paySellerAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="含应开票给个人的个人红包"
              align="center" show-overflow-tooltip
              prop="invoiceTip"
              width="200"
            ></el-table-column>
            <el-table-column
              label="是否信用购"
              align="center" show-overflow-tooltip
              prop="hasCreditBuy"
              width="180"
            ></el-table-column>
            <el-table-column
              label="体验期结束时间"
              align="center" show-overflow-tooltip
              prop="experienceEndTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="前N有礼"
              align="center" show-overflow-tooltip
              prop="aheadPresent"
              width="180"
            ></el-table-column>
            <el-table-column
              label="配送类型"
              align="center" show-overflow-tooltip
              prop="deliveryType"
              width="180"
            ></el-table-column>
            <el-table-column
              label="直播返现状态"
              align="center" show-overflow-tooltip
              prop="liveReturnStatus"
              width="180"
            ></el-table-column>
            <el-table-column
              label="返现金额"
              align="center" show-overflow-tooltip
              prop="cashbackAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="延迟发货赔付金额"
              align="center" show-overflow-tooltip
              prop="delayPayAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售成交门店昵称"
              align="center" show-overflow-tooltip
              prop="newDealStoreName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售成交门店id"
              align="center" show-overflow-tooltip
              prop="newDealStoreId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="新零售成交经销商id"
              align="center" show-overflow-tooltip
              prop="newDealAgentId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="预售订单"
              align="center" show-overflow-tooltip
              prop="presaleOrder"
              width="180"
            ></el-table-column>
            <el-table-column
              label="发货时间"
              align="center" show-overflow-tooltip
              prop="deliveryTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="主订单编号"
              align="center" show-overflow-tooltip
              prop="mainOrderNum"
              width="180"
            ></el-table-column>
            <el-table-column
              label="补差订单"
              align="center" show-overflow-tooltip
              prop="differentOrder"
              width="180"
            ></el-table-column>
          </el-table>
          <pagination
            v-if="total > 0"
            v-model:total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="handleQuery"
          />
        </el-card>
      </el-col>
    </el-row>

  </div>
</template>
